//1.装饰器模式定义
export {}
abstract class Shape {
  abstract draw(): void;
};

class  Circle extends Shape {
  draw(): void{
    console.log('画出一个圆形')
  }
}
class  Rectangle extends Shape {
  draw(): void{
    console.log('画出一个矩形')
  }
}
class  Star extends Shape {
  draw(): void{
    console.log('画出一个星形')
  }
}
//装饰器模式
abstract class ColorfulShape extends Shape {
  constructor(public shape:Shape) {
    super()
  }
  abstract draw():void;
};
class RedColorfulShape extends ColorfulShape{
  draw() {
    this.shape.draw();
      console.log('把边框涂成红色')
    }
}
class GreenColorfulShape extends ColorfulShape{
  draw() {
    this.shape.draw();
      console.log('把边框涂成绿色')
    }
}
//画出一个绿色的圆形
let greenColorfulShape = new GreenColorfulShape(new Circle());
greenColorfulShape.draw();
//画出一个红色的星形
let redColorfulShape = new RedColorfulShape(new Star());
redColorfulShape.draw();
